const app = new Vue({
  el: "#app",
  // 在此处补全代码，实现二级菜单搜索功能
  data: {
    menuList: [],
    searText: "",
  },
  computed: {
    filterList() {
      if (!this.searText) {
        return this.menuList
      }
      return this.menuList.filter((item) => {
        if (item.meta.title.includes(this.searText)) return item
        if (item.children?.length) {
          for (childItem of item.children) {
            if (childItem.meta.title.includes(this.searText)) return item
          }
        }
      })
    },
  },
  async created() {
    const { data } = await axios.get("data.json")
    console.log(data)
    this.menuList = data
  },
})
